package com.zd.bms.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.zd.bms.bean.vo.req.SystemLogListReqVo;
import com.zd.bms.service.ISysLogService;
import com.zd.common.bean.model.BmsUser;
import com.zd.common.bean.model.SysLog;
import com.zd.common.dao.common.Page;

@Controller
@RequestMapping("/system")
public class SystemController  extends BaseController{
	@Autowired
	private ISysLogService sysLogService;
	
	@RequestMapping("/log/index")
	public ModelAndView index() throws Exception{//取票
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/systemLog/index");
		return mv;
	}
	
	@ResponseBody
	@RequestMapping("/log/list")
	public Map<String, Object> list(SystemLogListReqVo reqVo) throws Exception {
		Map<String, Object> resultMap = new HashMap<>();
		BmsUser bmsUser = getSessionUser();
		Integer scenicSpotId = bmsUser.getScenicSpotId();
		if (scenicSpotId != null && scenicSpotId != 0) {
			reqVo.setScenicSpotId(scenicSpotId);
		}
		Page<SysLog> sysLogPage = sysLogService.pageSysLog(reqVo);

		resultMap.put("data", sysLogPage.getList());
		resultMap.put("draw", reqVo.getDraw());
		resultMap.put("recordsTotal", sysLogPage.getList().size());
		resultMap.put("recordsFiltered", sysLogPage.getTotalRow());
		return resultMap;
	}
}
